<?  require_once("header.php"); ?> 
<style>
#pagehistory li.selected {
position:relative;
}
#pagehistory li {
border:1px solid white;
}
#pagehistory li.selected {
background-color:#F9F9F9;
border:1px dashed #AAAAAA;
}
</style>

<div id="svnListArea" style="padding:5px;">
<form name=compareform id=compareform action="LocalRepoBrowser.php" method="GET">
<ul id="pagehistory">
<?
$first = true;

?>

        <li><input type="radio" value="TRUNK" name="oldid" /><input type="radio" value="TRUNK" checked="checked" name="diff" /> TRUNK</li>
<?

    foreach( $history->entries as $listEntry ) {
        $author   = $listEntry->author;
        $revision = $listEntry->revision;
        $isdir    = $listEntry->isdir;
        $name     = $listEntry->name;
        $date     = $listEntry->date;
        $comment  = $listEntry->comment;

        
?>
        <li><input type="radio" value="<?=$name?>" <?=($first)?"checked=checked":""?> name="oldid" /><input type="radio" value="<?=$name?>" name="diff" /> <?=$name?> &nbsp;( <?=$date?> )</li>
<?
        $first = false;
    }
?>
</ul>
<input type="hidden" name="serviceid" value="<?=$serviceId?>" />
<input type="hidden" name="repoid" value="<?=$repoId?>" />
<input type="hidden" name="bwstype" value="historydiff" />
<input type="submit" />
</form>

<script>
function histrowinit() {
    var hf = document.getElementById('pagehistory');
    if (!hf)
        return;
    var lis = hf.getElementsByTagName('li');
    for (var i = 0; i < lis.length; i++) {
        var inputs = historyRadios(lis[i]);
        if (inputs[0] && inputs[1]) {
            inputs[0].onclick = diffcheck;
            inputs[1].onclick = diffcheck;
        }
    }
    diffcheck();
}


function historyRadios(parent) {
    var inputs = parent.getElementsByTagName('input');
    var radios = [];
    for (var i = 0; i < inputs.length; i++) {
        if (inputs[i].name == "diff" || inputs[i].name == "oldid")
            radios[radios.length] = inputs[i];
    }
    return radios;
}

// check selection and tweak visibility/class onclick
function diffcheck() {
    var dli = false; // the li where the diff radio is checked
    var oli = false; // the li where the oldid radio is checked
    var hf = document.getElementById('pagehistory');
    if (!hf)
        return true;
    var lis = hf.getElementsByTagName('li');
    for (i=0;i<lis.length;i++) {
        var inputs = historyRadios(lis[i]);
        if (inputs[1] && inputs[0]) {
            if (inputs[1].checked || inputs[0].checked) { // this row has a checked radio button
                if (inputs[1].checked && inputs[0].checked && inputs[0].value == inputs[1].value)
                    return false;
                if (oli) { // it's the second checked radio
                    if (inputs[1].checked) {
                        oli.className = "selected";
                        return false;
                    }
                } else if (inputs[0].checked) {
                    return false;
                }
                if (inputs[0].checked)
                    dli = lis[i];
                if (!oli)
                    inputs[0].style.visibility = 'hidden';
                if (dli)
                    inputs[1].style.visibility = 'hidden';
                lis[i].className = "selected";
                oli = lis[i];
            }  else { // no radio is checked in this row
                if (!oli)
                    inputs[0].style.visibility = 'hidden';
                else
                    inputs[0].style.visibility = 'visible';
                if (dli)
                    inputs[1].style.visibility = 'hidden';
                else
                    inputs[1].style.visibility = 'visible';
                lis[i].className = "";
            }
        }
    }
    return true;
}

histrowinit();
</script>
<? require_once("footer.php"); ?>

